package com.example.security.service;

import com.example.security.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:UserService <br/>
 * description:  <br/>
 * Date:     2019/5/16、17:15 <br/>
 *
 * @author Plank
 */
public class UserService implements UserDetailsService {

    @Autowired
    private UserDao userDao;
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        List<GrantedAuthority> auths = new ArrayList<>();
        /*for (Role role : user.getRoles()) {
            auths.add(new SimpleGrantedAuthority(role.getName())); //不同用户会返回不同的role.name：USER, ADMIN
        }*/
        return new User("userName","password",auths);
    }
}
